package test.runtime;

import service.network.NetworkCalculationService;
import materials.network.NetworkInterface;

public class Rechenvieh {

	NetworkInterface _ni;
	double _fehler;
	
	public Rechenvieh(NetworkInterface ni){
		_ni = ni;
		_fehler = 0;
	}
	
	
	public void calculateInput(double[] inpvect){	
		NetworkCalculationService ncs = new NetworkCalculationService(_ni);
		double[] out = ncs.calculateInput(inpvect);	
		
		_fehler += Math.pow(Math.abs((inpvect[0] / 10.0) - (out[0])) + Math.abs((inpvect[1] / 10.0) - (out[1])),2);
	}
	
	public double getFitness(){
		return (0.01 /_fehler);
	}
	
	
	public void resetFitness(){
		_fehler = 0;
	}
	
	public NetworkInterface getNet(){
		return _ni;
	}
}
